from django.db import models


# Create your models here.
class Enterprise(models.Model):
    name = models.CharField(unique=True, max_length=30)
    address = models.CharField(max_length=30)
    type = models.CharField(max_length=1)
    projectId = models.ForeignKey('Researchproject', models.DO_NOTHING, db_column='projectId', blank=True,
                                  null=True)

    class Meta:
        db_table = 'enterprise'


class Linkman(models.Model):
    name = models.CharField(unique=True, max_length=30)
    phoneNumber = models.CharField(db_column='phoneNumber', max_length=20)
    email = models.CharField(max_length=30, blank=True, null=True)
    type = models.CharField(max_length=1)

    enterpriseId = models.ForeignKey('Enterprise', models.DO_NOTHING, db_column='enterpriseId', blank=True,null=True)

    class Meta:
        db_table = 'linkman'


class Office(models.Model):
    name = models.CharField(unique=True, max_length=30)
    area = models.IntegerField()
    researchRoomListId = models.ForeignKey('Researchroomlist', models.DO_NOTHING, db_column='ResearchRoomlistID',
                                           blank=True, null=True)

    class Meta:
        db_table = 'office'


class Participate(models.Model):
    projectId = models.ForeignKey('Researchproject', models.DO_NOTHING,
                                  db_column='projectId')
    researcherId = models.ForeignKey('Researcher', models.DO_NOTHING, db_column='ResearcherId', blank=True,
                                     null=True)
    fund = models.IntegerField()
    startTime = models.DateField(db_column='startTime', blank=True, null=True)
    workLoad = models.IntegerField(blank=True, null=True)
    type = models.CharField(max_length=1, blank=True, null=True)

    class Meta:
        db_table = 'participate'


class Researcher(models.Model):
    name = models.CharField(unique=True, max_length=30)
    sex = models.CharField(max_length=1, blank=True, null=True)
    title = models.CharField(max_length=30, blank=True, null=True)
    age = models.IntegerField(blank=True, null=True)
    researchDirection = models.CharField(db_column='researchDirection', max_length=30)
    researchRoomListId = models.ForeignKey('Researchroomlist', models.DO_NOTHING, db_column='ResearchRoomlistID',
                                           blank=True, null=True)

    class Meta:
        db_table = 'researcher'


class Researchproject(models.Model):
    name = models.CharField(unique=True, max_length=30)
    researchDirection = models.CharField(db_column='researchDirection', max_length=200)
    fund = models.IntegerField()
    startTime = models.DateField(db_column='startTime', blank=True, null=True)
    endTime = models.DateField(db_column='endTime', blank=True, null=True)
    leaderId = models.ForeignKey(Researcher, models.DO_NOTHING, db_column='leaderId', blank=True,
                                 null=True)  # Field name made lowercase.

    class Meta:
        db_table = 'researchproject'


class Researchroomlist(models.Model):
    name = models.CharField(unique=True, max_length=30)
    researchDirection = models.CharField(db_column='researchDirection', max_length=30)
    secretaryId = models.ForeignKey('Secretary', models.DO_NOTHING, db_column='secretaryID', blank=True,
                                    null=True)

    class Meta:
        db_table = 'researchroomlist'


class Scientificpayoffs(models.Model):
    name = models.CharField(unique=True, max_length=30)
    type = models.CharField(max_length=1)
    getTime = models.DateField(db_column='getTime')
    ranking = models.IntegerField(blank=True, null=True)
    projectId = models.ForeignKey(Researchproject, models.DO_NOTHING,
                                  db_column='projectId')

    class Meta:
        db_table = 'scientificpayoffs'


class Secretary(models.Model):
    name = models.CharField(unique=True, max_length=30)
    sex = models.CharField(max_length=1, blank=True, null=True)
    age = models.IntegerField(blank=True, null=True)
    employmentTime = models.DateField(blank=True, null=True)
    responsibility = models.CharField(max_length=30, blank=True, null=True)

    class Meta:
        db_table = 'secretary'


class Subproject(models.Model):
    name = models.CharField(unique=True, max_length=30)
    researchDirection = models.CharField(db_column='researchDirection', max_length=200)
    fund = models.IntegerField()
    deadline = models.DateField(blank=True, null=True)
    projectId = models.ForeignKey(Researchproject, models.DO_NOTHING,
                                  db_column='projectId')
    leaderId = models.ForeignKey(Researcher, models.DO_NOTHING, db_column='leaderId', blank=True,
                                 null=True)

    class Meta:
        db_table = 'subproject'


class User(models.Model):
    name = models.CharField(unique=True, null=True, max_length=30)
    password = models.CharField(max_length=30, null=True)
    root = models.CharField(max_length=1, null=True)

    class Meta:
        db_table = 'user'
